import request from './index.js';
import { encrypt } from '@/utils/sms4util';

export default {
  //登录
  login: (data) =>
    request({
      url: `/sys/login`,
      data: data,
      method: 'POST',
    }),
  //注册
  register: (data) =>
    request({
      url: `/sys/user/register`,
      data: data,
      method: 'POST',
    }),
  //忘记密码
  forgetPassword: (data) =>
    request({
      url: `/sys/user/passwordChange`,
      data: data,
      method: 'post',
    }),
  //获取验证码
  getCode: (data) =>
    request({
      url: `/sys/randomImage/${data}`,
      method: 'get',
    }),
  //忘记密码 法人获取账户
  getUserName: (data) =>
   request({
     url: `/sys/getUserName`,
     data: data,
     method: 'get',
   }),
  //获取个人信息、法人信息
  getUserInfo: (data) =>
   request({
     url: `/sys/user/getById`,
     data: data,
     method: 'get',
   }),
  //编辑提交个人信息、法人信息
  editUserInfo: (data) =>
   request({
     url: `/sys/user/updateUserInfo`,
     data: {
         ...data,
         unitTel: data.unitTel ? encrypt(data.unitTel) : undefined,
         creditCode: data.creditCode ? encrypt(data.creditCode) : undefined,
         phone: data.phone ? encrypt(data.phone) : undefined,
         paperCode: data.paperCode ? encrypt(data.paperCode) : undefined,
     },
     method: 'put',
   }),
  // 编辑三类人员信息
  editSafeInfo: (data) =>
    request({
      url: '/sysUserSafeQua/edit',
      data: data,
      method: 'put'
  }),
  //编辑提交企业资质
  editCompanyQualifications: (data) =>
   request({
     url: `/sysUnitQua/edit`,
     data: data,
     method: 'put',
   }),
    // token 登录
    loginWithToken: (data) =>
    request({
        url: `/sys/loginWithToken`,
        data: data,
        method: 'GET',
    }),
    getDownloadFile: (data) =>
        request({
            url: `/apply/getCertByUserIdAndCertCode`,
            data: data,
            method: 'GET',
        }),
    // 查询水利部三类人员电子证照
    getCertInfoFromMwr: (data) =>
        request({
            url: `/mwr/queryByHolderCode`,
            data: data,
            method: 'GET',
        })
};
